package com.dc.designPattern._3_prototype.deepClone;

/**
 * Description: 演示深拷贝 客户端
 * @author: gdc
 * @date: 2021/3/8
 * @version 1.0
 */
public class Client {

	public static void main(String[] args) throws Exception {
		DeepProtoType p = new DeepProtoType();
		p.name = "宋江";
		p.deepCloneableTarget = new DeepCloneableTarget("大牛", "小牛");

		//方式1 完成深拷贝
		//DeepProtoType p2 = (DeepProtoType) p.clone();
		//System.out.println("p.name=" + p.name + "\t p.deepCloneableTarget=" + p.deepCloneableTarget.hashCode());
		//System.out.println("p2.name=" + p.name + "\t p2.deepCloneableTarget=" + p2.deepCloneableTarget.hashCode());

		//方式2 完成深拷贝
		DeepProtoType p2 = (DeepProtoType) p.deepClone();
		System.out.println("p.name=" + p.name + "\t p.deepCloneableTarget=" + p.deepCloneableTarget.hashCode());
		System.out.println("p2.name=" + p.name + "\t p2.deepCloneableTarget=" + p2.deepCloneableTarget.hashCode());
	}
}
